package com.pengtu.entity.app;

// $ Generated 2008-10-21 16:35:41 by Hibernate Tools 3.1.0.beta4 $

import java.io.File;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.pengtu.entity.IdEntity;

/**
 * @struts.form include-all="true" extends="BaseForm"
 * @hibernate.class table="attachment"
 * 
 */
@Entity
@Table(name = "T_APP_ATTACHMENT")
@JsonAutoDetect 
@JsonIgnoreProperties (value = { "upfile" ,  "uploadFile" })  
public class Attachment extends IdEntity implements java.io.Serializable,
		Cloneable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 6875371342772935453L;
	/**
	 * id
	 */
	
	private File upfile; // 文件
	private String upfileContentType; // 文件类型
	
	private String upfileFileName; // 文件原始名
	private String savePath = "uploadFile"; // 文件存放路径
	private String fullPath; // 文件的完整路径
	private String path; // 文件最后的路径
	private String type; // 文件类型
	private String uploadPerson; // 上传的用户
	private String partId; // 对应与某一部分id 例如工程
	private String partName  ="公共文档夹"; // 对应与某一部分 例如工程
	private String tableId; // 对应表id
	private String tableName = "通用文件"; // 对应某表  例如工程的某部分
	private String tableField;	// 对应表中的某个字段
	private String fileName; // 文件名称
	private String fileNo; // 文件编号
	private Date fileTime; // 编制日期
	private String remark; // 文件的详细说明

	// Constructors

	/** default constructor */
	public Attachment() {
	}

	@Column(name="FILENAME")
	public String getFileName() {
		return fileName;
	}
	
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	@Column(name="FULLPATH")
	public String getFullPath() {
		return  fullPath;
	}
	public void setFullPath(String fullPath) {
		this.fullPath = fullPath;
	}

	@Column(name="PATH")
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Column(name="TYPE")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
   @Column(name="TABLEID")
	public String getTableId() {
		return tableId;
	}

	public void setTableId(String tableId) {
		this.tableId = tableId;
	}

	@Column(name="TABLENAME")
	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	@Column(name="TABLEFIELD")
	public String getTableField() {
		return tableField;
	}

	public void setTableField(String tableField) {
		this.tableField = tableField;
	}

	@Column(name="REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name="UPLOADPERSON")
	public String getUploadPerson() {
		return uploadPerson;
	}

	@Transient
	public File getUpfile() {
		return upfile;
	}

	public void setUpfile(File upfile) {
		this.upfile = upfile;
	}

	@Column(name="UPFILECONTENTTYPE")
	public String getUpfileContentType() {
		return upfileContentType;
	}

	public void setUpfileContentType(String upfileContentType) {
		this.upfileContentType = upfileContentType;
	}

	@Column(name="UPFILEFILENAME")
	public String getUpfileFileName() {
		return upfileFileName;
	}

	public void setUpfileFileName(String upfileFileName) {
		this.upfileFileName = upfileFileName;
	}

	@Column(name="SAVEPATH")
	public String getSavePath() {
		return savePath;
	}

	public void setSavePath(String savePath) {
		this.savePath = savePath;
	}

	public void setUploadPerson(String uploadPerson) {
		this.uploadPerson = uploadPerson;
	}

	@Column(name="FILETIME")
	public Date getFileTime() {
		return fileTime;
	}

	public void setFileTime(Date fileTime) {
		this.fileTime = fileTime;
	}
	@Column(name="FILENO")
	public String getFileNo() {
		return fileNo;
	}

	public void setFileNo(String fileNo) {
		this.fileNo = fileNo;
	}

	@Column(name="PARTID")
	public String getPartId() {
		return partId;
	}

	public void setPartId(String partId) {
		this.partId = partId;
	}
	@Column(name="PARTNAME")
	public String getPartName() {
		return partName;
	}

	public void setPartName(String partName) {
		this.partName = partName;
	}
	
	private String result;
	public void setResult(String result){
		this.result = result;
	}
	@Transient
	public String getResult(){
		return result;
	}
	
	@Transient
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((fullPath == null) ? 0 : fullPath.hashCode());
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

	@Transient
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Attachment other = (Attachment) obj;
		if (fullPath == null) {
			if (other.fullPath != null)
				return false;
		} else if (!fullPath.equals(other.fullPath))
			return false;
		if (path == null) {
			if (other.path != null)
				return false;
		} else if (!path.equals(other.path))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("tableId", this.tableId).append("path", this.path)
				.append("fullPath", this.fullPath).append("type", this.type)
				.append("uploadUser", this.uploadPerson).toString();
	}
}
